package com.wutianyi.datanucleus.dataobject;

import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.annotations.DatastoreIdentity;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;

@PersistenceCapable(identityType=IdentityType.DATASTORE)
@DatastoreIdentity(strategy=IdGeneratorStrategy.INCREMENT)
public class DataStoreIdentity {
	
	private String name;
	
	public DataStoreIdentity(String _name) {
		this.name = _name;
	}
	
	public static void main(String[] args) {
		PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("datanucleus.properties");
		PersistenceManager pm = pmf.getPersistenceManager();
		
		DataStoreIdentity dsi = new DataStoreIdentity("wutianyi");
		try {
			pm.makePersistent(dsi);
			Object id = pm.getObjectId(dsi);
			System.out.println(id.toString());
		}
		finally {
			pm.close();
		}
	}
}
